package com.jx.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.jx.service.DelAdminsService;
import com.jx.servicrimpl.DelAdminsServiceImpl;
/**
 * 删除管理员
 * @author zzzzzzz
 *
 */
public class DelAdminsController extends HttpServlet{
	DelAdminsService das=new DelAdminsServiceImpl();
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doPost(req, resp);
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		//获取数据
 		String strids=req.getParameter("strIds");
 		//分割字符串
 		String strid[]=strids.split(",");
 		int result=0;
 		//循环转化，删除
 	 	for(int i=0;i<strid.length;i++){
 	 			int j=Integer.parseInt(strid[i]);
 	 			das.delAdminsService(j);
 	 			result+=1;
 	 	}
 	 	//判断是否成功，传回数据
 	 	PrintWriter pw=resp.getWriter();
 	 	if(result==strid.length){
 	 		pw.write("1");
 	 	}else{
 	 		
 	 		pw.write("0");
 	 	}
	}
}
